<template>
  <div>
      <div  style="width: 500px;breakgrangd" align='center'>
        <van-field label='姓名' v-model='form.name'/>
        <van-field label='金额' v-model='form.money'/>
        <van-field label='机构名称' v-model='form.company'/>


        客户经理： 
        <select v-model="form.manager_id">
          <option :value='i.id' v-for="i in managerlist" :key="i">{{i.name}}</option>
        </select>&emsp;&emsp;&emsp;
        
        注册来源：
        <select v-model="form.refromid">
          <option :value='i.id' v-for="i in refromlist" :key="i">{{i.name}}</option>
        </select>
        <br/>
        <button @click="addcust">提交</button>
    </div>
  </div>
   
</template>

<script>
import axios from 'axios';
export default {
  name: "lianxi003",
  data() {
    return {
      form:{},
      managerlist:[],
      refromlist:[]
    };
  },
  methods: {
    getmanager(){
      axios({url:'http://127.0.0.1:5000/managerlist',method:'get'}).then(res=>{
        this.managerlist = res.data.list
      })
    },
    getrefrom(){
      axios({url:'http://127.0.0.1:5000/getrefrom',method:'get'}).then(res=>{
        this.refromlist = res.data.list
      })
    },
    addcust(){
      axios({url:'http://127.0.0.1:5000/addcustomer',method:'post',data:this.form})
      .then(res=>{
        console.log(res)
        this.$toast.fail("添加成功");
      })
    }
  },
  mounted() {
    this.getmanager()
    this.getrefrom()
  },
};
</script>

<style scoped></style>